home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / dalla rivista / host contacted / jikes.lha / jikes-1.11 / src / semantic.h < prev    next >
C/C++ Source or Header  |  2000-01-06  |  60KB  |  1,309 lines

  1. // $Id: semantic.h,v 1.28 2000/01/06 07:47:24 lord Exp $
  2. //
  3. // This software is subject to the terms of the IBM Jikes Compiler
  4. // License Agreement available at the following URL:
  5. // http://www.ibm.com/research/jikes.
  6. // Copyright (C) 1996, 1998, International Business Machines Corporation
  7. // and others.  All Rights Reserved.
  8. // You must accept the terms of that agreement to use this software.
  9. //
  10. #ifndef semantic_INCLUDED
  11. #define semantic_INCLUDED
  12.  
  13. #include "config.h"
  14. #ifdef HAVE_WCHAR_H
  15. # include <wchar.h>
  16. #endif
  17. #include "ast.h"
  18. #include "diagnose.h"
  19. #include "error.h"
  20. #include "symbol.h"
  21. #include "control.h"
  22. #include "tuple.h"
  23. #include "set.h"
  24.  
  25. class cp_info;
  26. class TypeShadowSymbol;
  27.  
  28. //
  29. //
  30. //
  31. class SymbolTableStack
  32. {
  33. public:
  34.     void Push(SymbolTable *symtab) { table.Next() = symtab; }
  35.     void Pop()                     { if (table.Length() > 0) table.Reset(table.Length() - 1); }
  36.     int Size()                     { return table.Length(); }
  37.     SymbolTable *Top()             { return (SymbolTable *) (table.Length() > 0 ? table[table.Length() - 1] : NULL); }
  38.  
  39.     SymbolTable *operator[](const int i) { return table[i]; } /*  */
  40.  
  41.     //
  42.     // Search for a variable in a stack of symbol tables starting at the current symbol table
  43.     // and ending with the symbol table of the method from which this call originates.
  44.     //
  45.     VariableSymbol *FindVariableSymbol(NameSymbol *name_symbol)
  46.     {
  47.         for (int i = table.Length() - 1; i >= 0; i--)
  48.         {
  49.             VariableSymbol *symbol = table[i] -> FindVariableSymbol(name_symbol);
  50.             if (symbol)
  51.                 return symbol;
  52.         }
  53.         return (VariableSymbol *) NULL;
  54.     }
  55.  
  56.     //
  57.     // Search for a type in a stack of symbol tables starting at the current symbol table
  58.     // and ending with the symbol table of the method from which this call originates.
  59.     //
  60.     TypeSymbol* FindTypeSymbol(NameSymbol *name_symbol)
  61.     {
  62.         for (int i = table.Length() - 1; i >= 0; i--)
  63.         {
  64.             TypeSymbol *symbol = table[i] -> FindTypeSymbol(name_symbol);
  65.             if (symbol)
  66.                 return symbol;
  67.         }
  68.         return (TypeSymbol *) NULL;
  69.     }
  70.  
  71.     //
  72.     // Search for a label in a stack of symbol tables starting at the current symbol table
  73.     // and ending with the symbol table of the method from which this call originates.
  74.     //
  75.     LabelSymbol* FindLabelSymbol(NameSymbol *name_symbol)
  76.     {
  77.         for (int i = table.Length() - 1; i >= 0; i--)
  78.         {
  79.             LabelSymbol *label = table[i] -> FindLabelSymbol(name_symbol);
  80.             if (label)
  81.                 return label;
  82.         }
  83.         return (LabelSymbol *) NULL;
  84.     }
  85.  
  86. private:
  87.     Tuple<SymbolTable *> table;
  88. };
  89.  
  90.  
  91. //
  92. //
  93. //
  94. class ExceptionTableStack
  95. {
  96. public:
  97.     void Push(SymbolSet *set) { table.Next() = set; }
  98.     void       Pop()          { if (table.Length() > 0) table.Reset(table.Length() - 1); }
  99.     int        Size()         { return table.Length(); }
  100.     SymbolSet *Top()          { return (SymbolSet *) (table.Length() > 0 ? table[table.Length() - 1] : NULL); }
  101.  
  102. private:
  103.     Tuple<SymbolSet *> table;
  104. };
  105.  
  106.  
  107. //
  108. //
  109. //
  110. class StatementStack
  111. {
  112. public:
  113.     void Push(Ast *stmt) { info.Next() = stmt; }
  114.     void Pop()           { if (info.Length() > 0) info.Reset(info.Length() - 1); }
  115.     int Size()           { return info.Length(); }
  116.     Ast *Top()           { return (Ast *) (info.Length() > 0 ? info[info.Length() - 1] : NULL); }
  117.  
  118.     Ast *operator[](const int i) { return info[i]; }
  119.  
  120. private:
  121.     Tuple<Ast *> info;
  122. };
  123.  
  124.  
  125. //
  126. //
  127. //
  128. class BlockStack
  129. {
  130. public:
  131.     int max_size;
  132.  
  133.     void Push(AstBlock *block_)
  134.     {
  135.         block.Next() = block_;
  136.         index.Next() = 0;
  137.         if (block.Length() > max_size)
  138.             max_size = block.Length();
  139.     }
  140.  
  141.     void Pop()
  142.     {
  143.         int len = block.Length() - 1;
  144.         if (len >= 0)
  145.         {
  146.             block.Reset(len);
  147.             index.Reset(len);
  148.         }
  149.     }
  150.  
  151.     int Size() { return block.Length(); }
  152.     AstBlock *TopBlock() { return (AstBlock *) (block.Length() > 0 ? block[block.Length() - 1] : NULL); }
  153.  
  154.     AstBlock *operator[](const int i) { return block[i]; }
  155.  
  156.     int &TopMaxEnclosedVariableIndex()
  157.     {
  158.         if (index.Length() <= 0)
  159.             assert(false);
  160.         return index[index.Length() - 1];
  161.     }
  162.  
  163.     BlockStack() : max_size(0) {}
  164.  
  165. private:
  166.     Tuple<AstBlock *> block;
  167.     Tuple<int> index;
  168. };
  169.  
  170.  
  171. //
  172. //
  173. //
  174. class DefiniteFinalAssignmentStack
  175. {
  176. public:
  177.     void Push() { info.Next().Reset(); }
  178.     void Pop()  { if (info.Length() > 0) info.Reset(info.Length() - 1); }
  179.     int Size()  { return info.Length(); }
  180.     Tuple <AstExpression *> &Top()  { if (info.Length() == 0) assert(false); return info[info.Length() - 1]; }
  181.  
  182. private:
  183.     Tuple< Tuple<AstExpression *> > info;
  184. };
  185.  
  186.  
  187. //
  188. //
  189. //
  190. class DefiniteSets
  191. {
  192. public:
  193.     DefiniteSets(int set_size) : break_set(set_size),
  194.                                  continue_set(set_size),
  195.                                  return_set(set_size),
  196.                                  throw_set(set_size)
  197.     {}
  198.  
  199.     BitSet break_set,
  200.            continue_set,
  201.            return_set,
  202.            throw_set;
  203.  
  204.     void UniverseInit()
  205.     {
  206.         break_set.SetUniverse();
  207.         continue_set.SetUniverse();
  208.         return_set.SetUniverse();
  209.         throw_set.SetUniverse();
  210.     }
  211.  
  212.     void EmptyInit()
  213.     {
  214.         break_set.SetEmpty();
  215.         continue_set.SetEmpty();
  216.         return_set.SetEmpty();
  217.         throw_set.SetEmpty();
  218.     }
  219. };
  220.  
  221.  
  222. //
  223. //
  224. //
  225. class DefiniteBlockStack
  226. {
  227. public:
  228.  
  229.     void Push(AstBlock *block_)
  230.     {
  231.         definite_sets[top_index] -> UniverseInit();
  232.         final_sets[top_index] -> EmptyInit();
  233.  
  234.         if (locally_defined_variables)
  235.         {
  236.             if (top_index == 0)
  237.             {
  238.                 memset(local_variables[top_index], 0, locally_defined_variables[top_index] -> Size() * sizeof(VariableSymbol *));
  239.                 locally_defined_variables[top_index] -> SetEmpty();
  240.             }
  241.             else
  242.             {
  243.                 memmove(local_variables[top_index],
  244.                         local_variables[top_index - 1],
  245.                         locally_defined_variables[top_index] -> Size() * sizeof(VariableSymbol *));
  246.                 *locally_defined_variables[top_index] = *locally_defined_variables[top_index - 1];
  247.             }
  248.         }
  249.  
  250.         block[top_index] = block_;
  251.         top_index++;
  252.     }
  253.  
  254.     void Pop()
  255.     {
  256.         if (top_index > 0)
  257.              top_index--;
  258.         else assert(false);
  259.     }
  260.  
  261.     int Size()                 { return top_index; }
  262.     AstBlock *Block(int i)     { return block[i]; }
  263.     AstBlock *TopBlock()       { assert(top_index > 0); return block[top_index - 1]; }
  264.  
  265.     VariableSymbol **TopLocalVariables() { assert(top_index > 0 && local_variables); return local_variables[top_index - 1]; }
  266.     BitSet *TopLocallyDefinedVariables() { assert(top_index > 0 && locally_defined_variables); return locally_defined_variables[top_index - 1]; }
  267.  
  268.     BitSet &BreakSet(int i)    { return definite_sets[i] -> break_set; }
  269.     BitSet &ContinueSet(int i) { return definite_sets[i] -> continue_set; }
  270.     BitSet &ReturnSet(int i)   { return definite_sets[i] -> return_set; }
  271.     BitSet &ThrowSet(int i)    { return definite_sets[i] -> throw_set; }
  272.  
  273.     BitSet &TopBreakSet()      { assert(top_index > 0); return definite_sets[top_index - 1] -> break_set; }
  274.     BitSet &TopContinueSet()   { assert(top_index > 0); return definite_sets[top_index - 1] -> continue_set; }
  275.     BitSet &TopReturnSet()     { assert(top_index > 0); return definite_sets[top_index - 1] -> return_set; }
  276.     BitSet &TopThrowSet()      { assert(top_index > 0); return definite_sets[top_index - 1] -> throw_set; }
  277.  
  278.     BitSet &TopExitSet(BitSet &start_set)
  279.     {
  280.         assert(top_index > 0);
  281.  
  282.         exit_set  = start_set;
  283.         exit_set *= TopBreakSet();
  284.         exit_set *= TopContinueSet();
  285.         exit_set *= TopReturnSet();
  286.         exit_set *= TopThrowSet();
  287.  
  288.         return exit_set;
  289.     }
  290.  
  291.     BitSet &FinalBreakSet(int i)    { return final_sets[i] -> break_set; }
  292.     BitSet &FinalContinueSet(int i) { return final_sets[i] -> continue_set; }
  293.     BitSet &FinalReturnSet(int i)   { return final_sets[i] -> return_set; }
  294.     BitSet &FinalThrowSet(int i)    { return final_sets[i] -> throw_set; }
  295.  
  296.     BitSet &TopFinalBreakSet()      { assert(top_index > 0); return final_sets[top_index - 1] -> break_set; }
  297.     BitSet &TopFinalContinueSet()   { assert(top_index > 0); return final_sets[top_index - 1] -> continue_set; }
  298.     BitSet &TopFinalReturnSet()     { assert(top_index > 0); return final_sets[top_index - 1] -> return_set; }
  299.     BitSet &TopFinalThrowSet()      { assert(top_index > 0); return final_sets[top_index - 1] -> throw_set; }
  300.  
  301.     BitSet &TopFinalExitSet(BitSet &start_set)
  302.     {
  303.         assert(top_index > 0);
  304.  
  305.         exit_set  = start_set;
  306.         exit_set += TopFinalBreakSet();
  307.         exit_set += TopFinalContinueSet();
  308.         exit_set += TopFinalReturnSet();
  309.         exit_set += TopFinalThrowSet();
  310.  
  311.         return exit_set;
  312.     }
  313.  
  314.     DefiniteBlockStack(Control &control, int stack_size_, int set_size) : stack_size(stack_size_),
  315.                                                                           top_index(0),
  316.                                                                           exit_set(set_size)
  317.     {
  318.         block = new AstBlock*[stack_size];
  319.         definite_sets = new DefiniteSets*[stack_size];
  320.         final_sets = new DefiniteSets*[stack_size];
  321.         local_variables = (VariableSymbol ***) (control.option.g ? new VariableSymbol**[stack_size] : NULL);
  322.         locally_defined_variables = (BitSet **) (control.option.g ? new BitSet*[stack_size] : NULL);
  323.  
  324.         for (int i = 0; i < stack_size; i++)
  325.         {
  326.             definite_sets[i] = new DefiniteSets(set_size);
  327.             final_sets[i] = new DefiniteSets(set_size);
  328.             if (local_variables)
  329.             {
  330.                 local_variables[i] = new VariableSymbol*[set_size];
  331.                 locally_defined_variables[i] = new BitSet(set_size);
  332.             }
  333.         }
  334.     }
  335.  
  336.     ~DefiniteBlockStack()
  337.     {
  338.         for (int i = 0; i < stack_size; i++)
  339.         {
  340.             delete definite_sets[i];
  341.             delete final_sets[i];
  342.             if (local_variables)
  343.             {
  344.                 delete [] local_variables[i];
  345.                 delete locally_defined_variables[i];
  346.             }
  347.         }
  348.  
  349.         delete [] block;
  350.         delete [] definite_sets;
  351.         delete [] final_sets;
  352.         delete [] local_variables;
  353.         delete [] locally_defined_variables;
  354.     }
  355.  
  356. private:
  357.  
  358.     int stack_size,
  359.         top_index;
  360.     AstBlock **block;
  361.  
  362.     DefiniteSets **definite_sets,
  363.                  **final_sets;
  364.  
  365.     BitSet **locally_defined_variables;
  366.     VariableSymbol ***local_variables;
  367.  
  368.     BitSet exit_set;
  369. };
  370.  
  371.  
  372. //
  373. //
  374. //
  375. class DefiniteTryStack
  376. {
  377. public:
  378.  
  379.     void Push(AstTryStatement *try_statement_)
  380.     {
  381.         this -> try_statement[top_index] = try_statement_;
  382.         top_index++;
  383.     }
  384.  
  385.     void Pop()
  386.     {
  387.         if (top_index > 0)
  388.              top_index--;
  389.         else assert(false);
  390.     }
  391.  
  392.     int Size()                           { return top_index; }
  393.     AstTryStatement *TryStatement(int i) { return try_statement[i]; }
  394.     AstBlock *Block(int i)               { return block[i]; }
  395.     AstBlock *TopBlock()                 { assert(top_index > 0); return block[top_index - 1]; }
  396.     void SetTopBlock(AstBlock *block_)   { assert(top_index > 0); block[top_index - 1] = block_; }
  397.  
  398.     DefiniteTryStack(int stack_size_) : stack_size(stack_size_),
  399.                                         top_index(0)
  400.     {
  401.         block = new AstBlock*[stack_size];
  402.         try_statement = new AstTryStatement*[stack_size];
  403.     }
  404.  
  405.     ~DefiniteTryStack()
  406.     {
  407.         delete [] block;
  408.         delete [] try_statement;
  409.     }
  410.  
  411. private:
  412.  
  413.     int stack_size,
  414.         top_index;
  415.     AstBlock **block;
  416.     AstTryStatement **try_statement;
  417. };
  418.  
  419.  
  420. //
  421. //
  422. //
  423. class SemanticEnvironment
  424. {
  425. public:
  426.  
  427.     Semantic *sem;
  428.     SemanticEnvironment *previous;
  429.  
  430.     MethodSymbol   *this_method;
  431.     VariableSymbol *this_variable;
  432.     Ast            *explicit_constructor_invocation;
  433.     Ast            *ast_construct;
  434.  
  435.     SymbolTableStack symbol_table; // Points to symbol table on top of stack
  436.     ExceptionTableStack try_exception_table_stack;
  437.     StatementStack try_statement_stack,
  438.                    breakable_statement_stack,
  439.                    continuable_statement_stack;
  440.     BlockStack block_stack;
  441.  
  442.     SemanticEnvironment(Semantic *sem_, TypeSymbol *type_, SemanticEnvironment *previous_ = NULL)
  443.             : sem(sem_),
  444.               previous(previous_),
  445.               this_method(NULL),
  446.               this_variable(NULL),
  447.               explicit_constructor_invocation(NULL),
  448.               ast_construct(NULL),
  449.               _type(type_),
  450.               next(NULL)
  451.     {}
  452.  
  453.  
  454.     ~SemanticEnvironment()
  455.     {
  456.         delete next; // if there was any clone, get rid of it
  457.     }
  458.  
  459.     //
  460.     // Clone the immediate environment of "this" Semantic environment.
  461.     // The immediate environment consists primarily of the stack of symbol
  462.     // tables that are necessary for looking up local variables in the immediate
  463.     // environment.
  464.     //
  465.     SemanticEnvironment *GetEnvironment(Ast *ast)
  466.     {
  467.         SemanticEnvironment *clone = new SemanticEnvironment(sem, _type, NULL);
  468.         clone -> this_method = this -> this_method;
  469.         clone -> this_variable = this -> this_variable;
  470.         clone -> ast_construct = ast;
  471.         for (int i = 0; i < this -> symbol_table.Size(); i++)
  472.             clone -> symbol_table.Push(this -> symbol_table[i]);
  473.         clone -> next = this -> next;
  474.         this -> next = clone;
  475.  
  476.         return clone;
  477.     }
  478.  
  479.     TypeSymbol *Type() { return _type; }
  480.  
  481.     //
  482.     // Are we in a static area ?
  483.     //
  484.     inline bool StaticRegion()
  485.     {
  486.         return (this_variable && this_variable -> ACC_STATIC()) ||
  487.                (this_method   && this_method -> ACC_STATIC())   ||
  488.                (_type -> ACC_INTERFACE());
  489.     }
  490.  
  491. private:
  492.  
  493.     TypeSymbol *_type;
  494.     SemanticEnvironment *next; // use to link an environment to its clones.
  495. };
  496.  
  497.  
  498. //
  499. //
  500. //
  501. class SemanticEnvironmentStack
  502. {
  503. public:
  504.     void Push(SemanticEnvironment *env) { info.Next() = env; }
  505.  
  506.     void Pop()
  507.     {
  508.         if (info.Length() > 0)
  509.             info.Reset(info.Length() - 1);
  510.  
  511.         return;
  512.     }
  513.  
  514.     int Size() { return info.Length(); }
  515.  
  516.     SemanticEnvironment *Top() { return (SemanticEnvironment *) (info.Length() > 0 ? info[info.Length() - 1] : NULL); }
  517.  
  518.     SemanticEnvironment *operator[](const int i) { return info[i]; }
  519.  
  520. private:
  521.     Tuple<SemanticEnvironment *> info;
  522. };
  523.  
  524.  
  525. class Semantic
  526. {
  527. public:
  528.     //
  529.     //
  530.     //
  531.     Control &control;
  532.     FileSymbol *source_file_symbol;
  533.     LexStream *lex_stream;
  534.     AstCompilationUnit *compilation_unit;
  535.     DirectorySymbol *directory_symbol;
  536.  
  537.     SymbolSet types_to_be_processed;
  538.  
  539.     int return_code;
  540.  
  541.     PackageSymbol *Package() { return this_package; }
  542.  
  543.     void CheckPackage();
  544.     void ProcessTypeNames();
  545.     void ProcessImports();
  546.     void ProcessSuperTypeDependences(AstClassDeclaration *);
  547.     void ProcessSuperTypeDependences(AstInterfaceDeclaration *);
  548.  
  549.     LiteralValue *ComputeFinalValue(AstVariableDeclarator *);
  550.  
  551.     Semantic(Control &control_, FileSymbol *file_symbol_) : control(control_),
  552.                                                             source_file_symbol(file_symbol_),
  553.                                                             lex_stream(file_symbol_ -> lex_stream),
  554.                                                             compilation_unit(file_symbol_ -> compilation_unit),
  555.                                                             directory_symbol(file_symbol_ -> directory_symbol),
  556.                                                             return_code(0),
  557.                                                             error(NULL),
  558.                                                             this_package(file_symbol_ -> package),
  559.                                                             definitely_assigned_variables(NULL),
  560.                                                             possibly_assigned_finals(NULL),
  561.                                                             universe(NULL),
  562.                                                             definite_block_stack(NULL),
  563.                                                             definite_try_stack(NULL),
  564.                                                             definite_final_assignment_stack(NULL),
  565.                                                             definite_visible_variables(NULL)
  566.     {
  567.         ProcessExprOrStmt[Ast::LOCAL_VARIABLE_DECLARATION] = &Semantic::ProcessLocalVariableDeclarationStatement;
  568.         ProcessExprOrStmt[Ast::BLOCK]                      = &Semantic::ProcessBlock;
  569.         ProcessExprOrStmt[Ast::EXPRESSION_STATEMENT]       = &Semantic::ProcessExpressionStatement;
  570.         ProcessExprOrStmt[Ast::SYNCHRONIZED_STATEMENT]     = &Semantic::ProcessSynchronizedStatement;
  571.         ProcessExprOrStmt[Ast::IF]                         = &Semantic::ProcessIfStatement;
  572.         ProcessExprOrStmt[Ast::WHILE]                      = &Semantic::ProcessWhileStatement;
  573.         ProcessExprOrStmt[Ast::FOR]                        = &Semantic::ProcessForStatement;
  574.         ProcessExprOrStmt[Ast::SWITCH]                     = &Semantic::ProcessSwitchStatement;
  575.         ProcessExprOrStmt[Ast::DO]                         = &Semantic::ProcessDoStatement;
  576.         ProcessExprOrStmt[Ast::BREAK]                      = &Semantic::ProcessBreakStatement;
  577.         ProcessExprOrStmt[Ast::CONTINUE]                   = &Semantic::ProcessContinueStatement;
  578.         ProcessExprOrStmt[Ast::RETURN]                     = &Semantic::ProcessReturnStatement;
  579.         ProcessExprOrStmt[Ast::THROW]                      = &Semantic::ProcessThrowStatement;
  580.         ProcessExprOrStmt[Ast::TRY]                        = &Semantic::ProcessTryStatement;
  581.         ProcessExprOrStmt[Ast::EMPTY_STATEMENT]            = &Semantic::ProcessEmptyStatement;
  582.         ProcessExprOrStmt[Ast::CLASS]                      = &Semantic::ProcessClassDeclaration;
  583.  
  584.         ProcessExprOrStmt[Ast::IDENTIFIER]               = &Semantic::ProcessSimpleName;
  585.         ProcessExprOrStmt[Ast::DOT]                      = &Semantic::ProcessFieldAccess;
  586.         ProcessExprOrStmt[Ast::INTEGER_LITERAL]          = &Semantic::ProcessIntegerLiteral;
  587.         ProcessExprOrStmt[Ast::LONG_LITERAL]             = &Semantic::ProcessLongLiteral;
  588.         ProcessExprOrStmt[Ast::FLOATING_POINT_LITERAL]   = &Semantic::ProcessFloatingPointLiteral;
  589.         ProcessExprOrStmt[Ast::DOUBLE_LITERAL]           = &Semantic::ProcessDoubleLiteral;
  590.         ProcessExprOrStmt[Ast::TRUE_LITERAL]             = &Semantic::ProcessTrueLiteral;
  591.         ProcessExprOrStmt[Ast::FALSE_LITERAL]            = &Semantic::ProcessFalseLiteral;
  592.         ProcessExprOrStmt[Ast::STRING_LITERAL]           = &Semantic::ProcessStringLiteral;
  593.         ProcessExprOrStmt[Ast::CHARACTER_LITERAL]        = &Semantic::ProcessCharacterLiteral;
  594.         ProcessExprOrStmt[Ast::NULL_LITERAL]             = &Semantic::ProcessNullLiteral;
  595.         ProcessExprOrStmt[Ast::ARRAY_ACCESS]             = &Semantic::ProcessArrayAccess;
  596.         ProcessExprOrStmt[Ast::CALL]                     = &Semantic::ProcessMethodInvocation;
  597.         ProcessExprOrStmt[Ast::THIS_EXPRESSION]          = &Semantic::ProcessThisExpression;
  598.         ProcessExprOrStmt[Ast::SUPER_EXPRESSION]         = &Semantic::ProcessSuperExpression;
  599.         ProcessExprOrStmt[Ast::PARENTHESIZED_EXPRESSION] = &Semantic::ProcessParenthesizedExpression;
  600.         ProcessExprOrStmt[Ast::CLASS_CREATION]           = &Semantic::ProcessClassInstanceCreationExpression;
  601.         ProcessExprOrStmt[Ast::ARRAY_CREATION]           = &Semantic::ProcessArrayCreationExpression;
  602.         ProcessExprOrStmt[Ast::POST_UNARY]               = &Semantic::ProcessPostUnaryExpression;
  603.         ProcessExprOrStmt[Ast::PRE_UNARY]                = &Semantic::ProcessPreUnaryExpression;
  604.         ProcessExprOrStmt[Ast::CAST]                     = &Semantic::ProcessCastExpression;
  605.         ProcessExprOrStmt[Ast::BINARY]                   = &Semantic::ProcessBinaryExpression;
  606.         ProcessExprOrStmt[Ast::TYPE]                     = &Semantic::ProcessTypeExpression;
  607.         ProcessExprOrStmt[Ast::CONDITIONAL]              = &Semantic::ProcessConditionalExpression;
  608.         ProcessExprOrStmt[Ast::ASSIGNMENT]               = &Semantic::ProcessAssignmentExpression;
  609.  
  610.         DefiniteStmt[Ast::LOCAL_VARIABLE_DECLARATION] = &Semantic::DefiniteLocalVariableDeclarationStatement;
  611.         DefiniteStmt[Ast::BLOCK]                      = &Semantic::DefiniteBlock;
  612.         DefiniteStmt[Ast::EXPRESSION_STATEMENT]       = &Semantic::DefiniteExpressionStatement;
  613.         DefiniteStmt[Ast::SYNCHRONIZED_STATEMENT]     = &Semantic::DefiniteSynchronizedStatement;
  614.         DefiniteStmt[Ast::IF]                         = &Semantic::DefiniteIfStatement;
  615.         DefiniteStmt[Ast::WHILE]                      = &Semantic::DefiniteWhileStatement;
  616.         DefiniteStmt[Ast::FOR]                        = &Semantic::DefiniteForStatement;
  617.         DefiniteStmt[Ast::SWITCH]                     = &Semantic::DefiniteSwitchStatement;
  618.         DefiniteStmt[Ast::DO]                         = &Semantic::DefiniteDoStatement;
  619.         DefiniteStmt[Ast::BREAK]                      = &Semantic::DefiniteBreakStatement;
  620.         DefiniteStmt[Ast::CONTINUE]                   = &Semantic::DefiniteContinueStatement;
  621.         DefiniteStmt[Ast::RETURN]                     = &Semantic::DefiniteReturnStatement;
  622.         DefiniteStmt[Ast::THROW]                      = &Semantic::DefiniteThrowStatement;
  623.         DefiniteStmt[Ast::TRY]                        = &Semantic::DefiniteTryStatement;
  624.         DefiniteStmt[Ast::EMPTY_STATEMENT]            = &Semantic::DefiniteEmptyStatement;
  625.         DefiniteStmt[Ast::CLASS]                      = &Semantic::DefiniteClassDeclaration;
  626.  
  627.         DefiniteExpr[Ast::IDENTIFIER]               = &Semantic::DefiniteSimpleName;
  628.         DefiniteExpr[Ast::DOT]                      = &Semantic::DefiniteFieldAccess;
  629.         DefiniteExpr[Ast::ARRAY_ACCESS]             = &Semantic::DefiniteArrayAccess;
  630.         DefiniteExpr[Ast::CALL]                     = &Semantic::DefiniteMethodInvocation;
  631.         DefiniteExpr[Ast::PARENTHESIZED_EXPRESSION] = &Semantic::DefiniteParenthesizedExpression;
  632.         DefiniteExpr[Ast::CLASS_CREATION]           = &Semantic::DefiniteClassInstanceCreationExpression;
  633.         DefiniteExpr[Ast::ARRAY_CREATION]           = &Semantic::DefiniteArrayCreationExpression;
  634.         DefiniteExpr[Ast::POST_UNARY]               = &Semantic::DefinitePostUnaryExpression;
  635.         DefiniteExpr[Ast::PRE_UNARY]                = &Semantic::DefinitePreUnaryExpression;
  636.         DefiniteExpr[Ast::CAST]                     = &Semantic::DefiniteCastExpression;
  637.         DefiniteExpr[Ast::CHECK_AND_CAST]           = &Semantic::DefiniteCastExpression;
  638.         DefiniteExpr[Ast::BINARY]                   = &Semantic::DefiniteBinaryExpression;
  639.         DefiniteExpr[Ast::CONDITIONAL]              = &Semantic::DefiniteConditionalExpression;
  640.         DefiniteExpr[Ast::ASSIGNMENT]               = &Semantic::DefiniteAssignmentExpression;
  641.  
  642.         DefiniteExpr[Ast::INTEGER_LITERAL]          = &Semantic::DefiniteDefaultExpression;
  643.         DefiniteExpr[Ast::LONG_LITERAL]             = &Semantic::DefiniteDefaultExpression;
  644.         DefiniteExpr[Ast::FLOATING_POINT_LITERAL]   = &Semantic::DefiniteDefaultExpression;
  645.         DefiniteExpr[Ast::DOUBLE_LITERAL]           = &Semantic::DefiniteDefaultExpression;
  646.         DefiniteExpr[Ast::TRUE_LITERAL]             = &Semantic::DefiniteDefaultExpression;
  647.         DefiniteExpr[Ast::FALSE_LITERAL]            = &Semantic::DefiniteDefaultExpression;
  648.         DefiniteExpr[Ast::STRING_LITERAL]           = &Semantic::DefiniteDefaultExpression;
  649.         DefiniteExpr[Ast::CHARACTER_LITERAL]        = &Semantic::DefiniteDefaultExpression;
  650.         DefiniteExpr[Ast::NULL_LITERAL]             = &Semantic::DefiniteDefaultExpression;
  651.         DefiniteExpr[Ast::THIS_EXPRESSION]          = &Semantic::DefiniteDefaultExpression;
  652.         DefiniteExpr[Ast::SUPER_EXPRESSION]         = &Semantic::DefiniteDefaultExpression;
  653.         DefiniteExpr[Ast::TYPE]                     = &Semantic::DefiniteDefaultExpression;
  654.  
  655.         DefiniteBinaryExpr[AstBinaryExpression::PLUS]                 = &Semantic::DefiniteDefaultBinaryExpression;
  656.         DefiniteBinaryExpr[AstBinaryExpression::LEFT_SHIFT]           = &Semantic::DefiniteDefaultBinaryExpression;
  657.         DefiniteBinaryExpr[AstBinaryExpression::RIGHT_SHIFT]          = &Semantic::DefiniteDefaultBinaryExpression;
  658.         DefiniteBinaryExpr[AstBinaryExpression::UNSIGNED_RIGHT_SHIFT] = &Semantic::DefiniteDefaultBinaryExpression;
  659.         DefiniteBinaryExpr[AstBinaryExpression::LESS]                 = &Semantic::DefiniteDefaultBinaryExpression;
  660.         DefiniteBinaryExpr[AstBinaryExpression::GREATER]              = &Semantic::DefiniteDefaultBinaryExpression;
  661.         DefiniteBinaryExpr[AstBinaryExpression::LESS_EQUAL]           = &Semantic::DefiniteDefaultBinaryExpression;
  662.         DefiniteBinaryExpr[AstBinaryExpression::GREATER_EQUAL]        = &Semantic::DefiniteDefaultBinaryExpression;
  663.  
  664.         //
  665.         // TODO: Remove this comment as well as the functions:
  666.         //
  667.         //     DefiniteAND
  668.         //     DefiniteXOR
  669.         //     DefiniteIOR
  670.         //
  671.         //     DefiniteEQUAL
  672.         //     DefiniteNOT_EQUAL
  673.         //
  674.         // when revised spec is released !!!
  675.         //
  676.         //****************************************************************************************
  677.         //
  678.         // To: Martin Odersky <Martin.Odersky@epfl.ch>
  679.         // cc: David Shields/Watson/IBM@IBMUS, compiler@eng.sun.com,
  680.         // gilad.bracha@eng.sun.com, jrose@eng.sun.com,
  681.         // innerclass-comments@lukasiewicz.eng.sun.com, guy.steele@east.sun.com,
  682.         // peter.kessler@eng.sun.com
  683.         // Subject: Re: Query #32 to Sun: Verification problem
  684.         //
  685.         //
  686.         //
  687.         //
  688.         // On Thu, 29 Jul 1999, Martin Odersky wrote:
  689.         //
  690.         // > It seems a very undesirable state of affairs if the Java spec for |,
  691.         // > &, ^ and the JVM spec for iand, ior, ixor differ in their definite
  692.         // > assignment properties. Assuming that it's unreasonable to make the
  693.         // > verifier implement the current JLS spec one-to-one, would it be
  694.         // > possible to tighten the JLS so that definite assignment for |, & ,^ is
  695.         // > done in the way the verifier does it? I doubt that such a tightening
  696.         // > would invalidate any real Java programs.
  697.         //
  698.         // Gilad and I decided today that ammending the JLS was the best course of
  699.         // action, and then discovered that Guy had already done so in our working
  700.         // draft of the revised specification.  We anticipate that when a draft is
  701.         // made
  702.         // available for public review, it will drop sections 16.1.6, 16.1.7, and
  703.         // 16.1.8, which specify special-case rules for the &, |, and ^ operators.
  704.         // They will be covered instead by the general case for expressions with
  705.         // subexpressions, which reads as follows in the current working draft:
  706.         //
  707.         //  If the expression has subexpressions, V is [un]assigned
  708.         //  after the expression iff V is [un]assigned after its rightmost
  709.         //  immediate subexpression.
  710.         //
  711.         // Note that the when-true and when-false cases, currently distinguished
  712.         // for these operators, are now coalesced, as in the general case.
  713.         //
  714.         // Pending an official change to the specification, we recommend that
  715.         // compiler implementors follow the proposed ammendments.
  716.         //
  717.         // Due to the fact that 'javac' has never been in compliance with the
  718.         // current JLS on this issue, nor will much (all?) code that
  719.         // relies on the difference actually verify and execute, compatibility
  720.         // implications should be minimal.
  721.         //
  722.         // --Bill
  723.         //
  724.         //------------------------------------------------------------------------------------------------
  725.         //
  726.         // To: David Shields/Watson/IBM@IBMUS
  727.         // cc: Martin Odersky <Martin.Odersky@epfl.ch>, compiler@eng.sun.com, gilad.bracha@eng.sun.com,
  728.         // jrose@eng.sun.com, innerclass-comments@lukasiewicz.eng.sun.com, guy.steele@east.sun.com,
  729.         // peter.kessler@eng.sun.com
  730.         // Subject: Re: Query #32 to Sun: Verification problem
  731.         //
  732.         // On Mon, 2 Aug 1999 shieldsd@us.ibm.com wrote:
  733.         //
  734.         // > Do you still plan to retain 16.1.3, 16.1.4 and 16.1.11? Since we follow them as
  735.         // > currently written, we accept some of the positive 1.2 JCK tests that javac
  736.         // > currently rejects, but the resulting class files fail verification. Examples
  737.         // > include dasg02901, dasg03001, dasg03301, dasg03303, dasg03401, dasg03501,
  738.         // > dasg04501, dasg04601, dasg04701 and dasg05001).
  739.         // >
  740.         // > dave and philippe
  741.         //
  742.         // We plan to keep these.  However, the special rules for '==' (16.1.9) and
  743.         // '!=' (16.1.10) have also been dropped, again because the bytecodes for these
  744.         // operators create materialized boolean values on the stack at runtime.
  745.         //
  746.         // Guy and Gilad:  In my copy of the draft, the second-to-last sentence on
  747.         // page p.395 claims otherwise, but sections 16.1.9 and 16.1.10 have in fact
  748.         // been deleted.
  749.         //
  750.         // --Bill
  751.         //
  752.         DefiniteBinaryExpr[AstBinaryExpression::AND]                  = &Semantic::DefiniteDefaultBinaryExpression;// &Semantic::DefiniteAND;
  753.         DefiniteBinaryExpr[AstBinaryExpression::XOR]                  = &Semantic::DefiniteDefaultBinaryExpression;// &Semantic::DefiniteXOR;
  754.         DefiniteBinaryExpr[AstBinaryExpression::IOR]                  = &Semantic::DefiniteDefaultBinaryExpression;// &Semantic::DefiniteIOR;
  755.  
  756.         DefiniteBinaryExpr[AstBinaryExpression::EQUAL_EQUAL]          = &Semantic::DefiniteDefaultBinaryExpression; // &Semantic::DefiniteEQUAL_EQUAL;
  757.         DefiniteBinaryExpr[AstBinaryExpression::NOT_EQUAL]            = &Semantic::DefiniteDefaultBinaryExpression; // &Semantic::DefiniteNOT_EQUAL;
  758.  
  759.         DefiniteBinaryExpr[AstBinaryExpression::AND_AND]              = &Semantic::DefiniteAND_AND;
  760.         DefiniteBinaryExpr[AstBinaryExpression::OR_OR]                = &Semantic::DefiniteOR_OR;
  761.         DefiniteBinaryExpr[AstBinaryExpression::STAR]                 = &Semantic::DefiniteDefaultBinaryExpression;
  762.         DefiniteBinaryExpr[AstBinaryExpression::MINUS]                = &Semantic::DefiniteDefaultBinaryExpression;
  763.         DefiniteBinaryExpr[AstBinaryExpression::SLASH]                = &Semantic::DefiniteDefaultBinaryExpression;
  764.         DefiniteBinaryExpr[AstBinaryExpression::MOD]                  = &Semantic::DefiniteDefaultBinaryExpression;
  765.         DefiniteBinaryExpr[AstBinaryExpression::INSTANCEOF]           = &Semantic::DefiniteDefaultBinaryExpression;
  766.  
  767.         DefinitePreUnaryExpr[AstPreUnaryExpression::PLUS]             = &Semantic::DefiniteDefaultPreUnaryExpression;
  768.         DefinitePreUnaryExpr[AstPreUnaryExpression::MINUS]            = &Semantic::DefiniteDefaultPreUnaryExpression;
  769.         DefinitePreUnaryExpr[AstPreUnaryExpression::TWIDDLE]          = &Semantic::DefiniteDefaultPreUnaryExpression;
  770.         DefinitePreUnaryExpr[AstPreUnaryExpression::NOT]              = &Semantic::DefiniteNOT;
  771.         DefinitePreUnaryExpr[AstPreUnaryExpression::PLUSPLUS]         = &Semantic::DefinitePLUSPLUSOrMINUSMINUS;
  772.         DefinitePreUnaryExpr[AstPreUnaryExpression::MINUSMINUS]       = &Semantic::DefinitePLUSPLUSOrMINUSMINUS;
  773.  
  774.         ProcessBinaryExpr[AstBinaryExpression::PLUS]                 = &Semantic::ProcessPLUS;
  775.         ProcessBinaryExpr[AstBinaryExpression::LEFT_SHIFT]           = &Semantic::ProcessLEFT_SHIFT;
  776.         ProcessBinaryExpr[AstBinaryExpression::RIGHT_SHIFT]          = &Semantic::ProcessRIGHT_SHIFT;
  777.         ProcessBinaryExpr[AstBinaryExpression::UNSIGNED_RIGHT_SHIFT] = &Semantic::ProcessUNSIGNED_RIGHT_SHIFT;
  778.         ProcessBinaryExpr[AstBinaryExpression::LESS]                 = &Semantic::ProcessLESS;
  779.         ProcessBinaryExpr[AstBinaryExpression::GREATER]              = &Semantic::ProcessGREATER;
  780.         ProcessBinaryExpr[AstBinaryExpression::LESS_EQUAL]           = &Semantic::ProcessLESS_EQUAL;
  781.         ProcessBinaryExpr[AstBinaryExpression::GREATER_EQUAL]        = &Semantic::ProcessGREATER_EQUAL;
  782.         ProcessBinaryExpr[AstBinaryExpression::AND]                  = &Semantic::ProcessAND;
  783.         ProcessBinaryExpr[AstBinaryExpression::XOR]                  = &Semantic::ProcessXOR;
  784.         ProcessBinaryExpr[AstBinaryExpression::IOR]                  = &Semantic::ProcessIOR;
  785.         ProcessBinaryExpr[AstBinaryExpression::AND_AND]              = &Semantic::ProcessAND_AND;
  786.         ProcessBinaryExpr[AstBinaryExpression::OR_OR]                = &Semantic::ProcessOR_OR;
  787.         ProcessBinaryExpr[AstBinaryExpression::EQUAL_EQUAL]          = &Semantic::ProcessEQUAL_EQUAL;
  788.         ProcessBinaryExpr[AstBinaryExpression::NOT_EQUAL]            = &Semantic::ProcessNOT_EQUAL;
  789.         ProcessBinaryExpr[AstBinaryExpression::STAR]                 = &Semantic::ProcessSTAR;
  790.         ProcessBinaryExpr[AstBinaryExpression::MINUS]                = &Semantic::ProcessMINUS;
  791.         ProcessBinaryExpr[AstBinaryExpression::SLASH]                = &Semantic::ProcessSLASH;
  792.         ProcessBinaryExpr[AstBinaryExpression::MOD]                  = &Semantic::ProcessMOD;
  793.         ProcessBinaryExpr[AstBinaryExpression::INSTANCEOF]           = &Semantic::ProcessINSTANCEOF;
  794.  
  795.         ProcessPreUnaryExpr[AstPreUnaryExpression::PLUS]       = &Semantic::ProcessPLUS;
  796.         ProcessPreUnaryExpr[AstPreUnaryExpression::MINUS]      = &Semantic::ProcessMINUS;
  797.         ProcessPreUnaryExpr[AstPreUnaryExpression::TWIDDLE]    = &Semantic::ProcessTWIDDLE;
  798.         ProcessPreUnaryExpr[AstPreUnaryExpression::NOT]        = &Semantic::ProcessNOT;
  799.         ProcessPreUnaryExpr[AstPreUnaryExpression::PLUSPLUS]   = &Semantic::ProcessPLUSPLUSOrMINUSMINUS;
  800.         ProcessPreUnaryExpr[AstPreUnaryExpression::MINUSMINUS] = &Semantic::ProcessPLUSPLUSOrMINUSMINUS;
  801.     }
  802.  
  803.     ~Semantic() { delete error; }
  804.  
  805.     void ReportSemError(SemanticError::SemanticErrorKind kind,
  806.                         LexStream::TokenIndex ltok,
  807.                         LexStream::TokenIndex rtok,
  808.                         wchar_t *s1 = NULL,
  809.                         wchar_t *s2 = NULL,
  810.                         wchar_t *s3 = NULL,
  811.                         wchar_t *s4 = NULL,
  812.                         wchar_t *s5 = NULL,
  813.                         wchar_t *s6 = NULL,
  814.                         wchar_t *s7 = NULL,
  815.                         wchar_t *s8 = NULL,
  816.                         wchar_t *s9 = NULL)
  817.     {
  818.         if (! error)
  819.             error = new SemanticError(control, source_file_symbol);
  820.         error -> Report(kind, ltok, rtok, s1, s2, s3, s4, s5, s6, s7, s8, s9);
  821.     }
  822.  
  823.     int NumErrors() { return (error ? error -> num_errors : 0); }
  824.  
  825.     //
  826.     // If we had a bad compilation unit, print the parser messages.
  827.     // If semantic errors were detected print them too.
  828.     // Set the return code.
  829.     //
  830.     void PrintMessages()
  831.     {
  832.         if (this != control.system_semantic)
  833.         {
  834.             if (lex_stream -> NumBadTokens() > 0)
  835.             {
  836.                 lex_stream -> PrintMessages();
  837.                 return_code = 1;
  838.             }
  839.  
  840.             if ((! compilation_unit) || compilation_unit -> BadCompilationUnitCast())
  841.             {
  842.                 DiagnoseParser *diagnose_parser = new DiagnoseParser(control, lex_stream);
  843.                 return_code = 1;
  844.                 delete diagnose_parser;
  845.             }
  846.  
  847.             if (! control.option.nocleanup)
  848.             if (compilation_unit)
  849.                 CleanUp();
  850.         }
  851.  
  852.         if (error && error -> error.Length() > 0 && error -> PrintMessages() > return_code)
  853.             return_code = 1;
  854.  
  855.         //
  856.         // Once we have processed the errors, reset the error object
  857.         //
  858.         delete error;
  859.         error = NULL;
  860.  
  861.         return;
  862.     }
  863.  
  864.     TypeSymbol *ProcessSignature(TypeSymbol *, char *, LexStream::TokenIndex);
  865.     TypeSymbol *ReadType(FileSymbol *, PackageSymbol *, NameSymbol *, LexStream::TokenIndex);
  866.     TypeSymbol *ReadTypeFromSignature(TypeSymbol *, char *, int, LexStream::TokenIndex);
  867.     TypeSymbol *ProcessNestedType(TypeSymbol *, NameSymbol *, LexStream::TokenIndex);
  868.  
  869. private:
  870.  
  871.     SemanticError *error;
  872.  
  873.     void CleanUp();
  874.     void CleanUpType(TypeSymbol *);
  875.  
  876.     void SetDefaultSuperType(AstClassDeclaration *);
  877.     void SetDefaultSuperType(AstInterfaceDeclaration *);
  878.     void ProcessTypeHeader(AstClassDeclaration *);
  879.     void MarkCircularNest(TypeSymbol *);
  880.     void ProcessSuperTypesOfOuterType(TypeSymbol *);
  881.     void ProcessSuperTypesOfInnerType(TypeSymbol *, Tuple<TypeSymbol *> &);
  882.     void ProcessTypeHeaders(AstClassDeclaration *);
  883.     TypeSymbol *FindTypeInLayer(Ast *, SymbolSet &);
  884.     void ProcessNestedSuperTypes(TypeSymbol *);
  885.     void ProcessNestedTypeHeaders(TypeSymbol *, AstClassBody *);
  886.     void ProcessTypeHeader(AstInterfaceDeclaration *);
  887.     void ProcessTypeHeaders(AstInterfaceDeclaration *);
  888.     void ProcessNestedTypeHeaders(AstInterfaceDeclaration *);
  889.     void ProcessConstructorMembers(AstClassBody *);
  890.     void ProcessMethodMembers(AstClassBody *);
  891.     void ProcessFieldMembers(AstClassBody *);
  892.     void ProcessMembers(SemanticEnvironment *, AstClassBody *);
  893.     void CompleteSymbolTable(SemanticEnvironment *, LexStream::TokenIndex, AstClassBody *);
  894.     void ProcessExecutableBodies(SemanticEnvironment *, AstClassBody *);
  895.     void ProcessExecutableBodies(AstInterfaceDeclaration *);
  896.  
  897.     void ProcessMethodMembers(AstInterfaceDeclaration *);
  898.     void ProcessFieldMembers(AstInterfaceDeclaration *);
  899.     void ProcessMembers(AstInterfaceDeclaration *);
  900.     void CompleteSymbolTable(AstInterfaceDeclaration *);
  901.  
  902.     friend class TypeSymbol;
  903.  
  904.     Tuple<Symbol *> import_on_demand_packages;
  905.     Tuple<TypeSymbol *> single_type_imports;
  906.  
  907.     //
  908.     // Where am I?
  909.     //
  910.     PackageSymbol  *this_package;
  911.  
  912.     TypeSymbol *ThisType()                        { assert(state_stack.Size()); return state_stack.Top() -> Type(); }
  913.     MethodSymbol *&ThisMethod()                   { assert(state_stack.Size()); return state_stack.Top() -> this_method; }
  914.     VariableSymbol *&ThisVariable()               { assert(state_stack.Size()); return state_stack.Top() -> this_variable; }
  915.     Ast *&ExplicitConstructorInvocation()         { assert(state_stack.Size()); return state_stack.Top() -> explicit_constructor_invocation; }
  916.     SymbolTableStack &LocalSymbolTable()          { assert(state_stack.Size()); return state_stack.Top() -> symbol_table; }
  917.     ExceptionTableStack &TryExceptionTableStack() { assert(state_stack.Size()); return state_stack.Top() -> try_exception_table_stack; }
  918.     StatementStack &TryStatementStack()           { assert(state_stack.Size()); return state_stack.Top() -> try_statement_stack; }
  919.     StatementStack &BreakableStatementStack()     { assert(state_stack.Size()); return state_stack.Top() -> breakable_statement_stack; }
  920.     StatementStack &ContinuableStatementStack()   { assert(state_stack.Size()); return state_stack.Top() -> continuable_statement_stack; }
  921.     BlockStack &LocalBlockStack()                 { assert(state_stack.Size()); return state_stack.Top() -> block_stack; }
  922.     SemanticEnvironment *GetEnvironment(Ast *ast) { assert(state_stack.Size()); return state_stack.Top() -> GetEnvironment(ast); }
  923.     bool StaticRegion()                           { assert(state_stack.Size()); return state_stack.Top() -> StaticRegion(); }
  924.  
  925.     SemanticEnvironmentStack state_stack;
  926.  
  927.     BitSet *definitely_assigned_variables,
  928.            *possibly_assigned_finals,
  929.            *universe;
  930.     DefiniteBlockStack *definite_block_stack;
  931.     DefiniteTryStack *definite_try_stack;
  932.     DefiniteFinalAssignmentStack *definite_final_assignment_stack;
  933.     SymbolSet *definite_visible_variables;
  934.  
  935.     bool IsIntValueRepresentableInType(AstExpression *, TypeSymbol *);
  936.  
  937.     void CheckClassMembers(TypeSymbol *, AstClassBody *);
  938.     void CheckNestedTypeDuplication(SemanticEnvironment *, LexStream::TokenIndex);
  939.     TypeSymbol *ProcessNestedClassName(TypeSymbol *, AstClassDeclaration *);
  940.     void CheckInterfaceMembers(TypeSymbol *, AstInterfaceDeclaration *);
  941.     TypeSymbol *ProcessNestedInterfaceName(TypeSymbol *, AstInterfaceDeclaration *);
  942.     TypeSymbol *FindTypeInShadow(TypeShadowSymbol *, LexStream::TokenIndex);
  943.     void ReportTypeInaccessible(LexStream::TokenIndex, LexStream::TokenIndex, TypeSymbol *);
  944.     void ReportTypeInaccessible(Ast *ast, TypeSymbol *type) { ReportTypeInaccessible(ast -> LeftToken(), ast -> RightToken(), type); }
  945.     TypeSymbol *GetBadNestedType(TypeSymbol *, LexStream::TokenIndex);
  946.     TypeSymbol *FindNestedType(TypeSymbol *, LexStream::TokenIndex);
  947.     TypeSymbol *MustFindNestedType(TypeSymbol *, Ast *);
  948.     void ProcessImportQualifiedName(AstExpression *);
  949.     void ProcessPackageOrType(AstExpression *);
  950.     void ProcessTypeImportOnDemandDeclaration(AstImportDeclaration *);
  951.     AstExpression *FindFirstType(Ast *);
  952.     TypeSymbol *FindSimpleNameType(PackageSymbol *, LexStream::TokenIndex);
  953.     void ProcessSingleTypeImportDeclaration(AstImportDeclaration *);
  954.     AccessFlags ProcessClassModifiers(AstClassDeclaration *);
  955.     AccessFlags ProcessLocalClassModifiers(AstClassDeclaration *);
  956.     AccessFlags ProcessNestedClassModifiers(AstClassDeclaration *);
  957.     AccessFlags ProcessStaticNestedClassModifiers(AstClassDeclaration *);
  958.     AccessFlags ProcessInterfaceModifiers(AstInterfaceDeclaration *);
  959.     AccessFlags ProcessNestedInterfaceModifiers(AstInterfaceDeclaration *);
  960.     AccessFlags ProcessFieldModifiers(AstFieldDeclaration *);
  961.     AccessFlags ProcessLocalModifiers(AstLocalVariableDeclarationStatement *);
  962.     AccessFlags ProcessFormalModifiers(AstFormalParameter *);
  963.     AccessFlags ProcessMethodModifiers(AstMethodDeclaration *);
  964.     AccessFlags ProcessConstructorModifiers(AstConstructorDeclaration *);
  965.     AccessFlags ProcessConstantModifiers(AstFieldDeclaration *);
  966.     AccessFlags ProcessAbstractMethodModifiers(AstMethodDeclaration *);
  967.     void AddDefaultConstructor(TypeSymbol *);
  968.     void ProcessConstructorDeclaration(AstConstructorDeclaration *);
  969.     void ProcessMethodDeclaration(AstMethodDeclaration *);
  970.     void ProcessFieldDeclaration(AstFieldDeclaration *);
  971.     void ProcessFormalParameters(BlockSymbol *, AstMethodDeclarator *);
  972.     TypeSymbol *ImportType(LexStream::TokenIndex, NameSymbol *);
  973.     TypeSymbol *FindPrimitiveType(AstPrimitiveType *);
  974.     TypeSymbol *FindTypeInEnvironment(SemanticEnvironment *, NameSymbol *);
  975.     TypeSymbol *FindType(LexStream::TokenIndex);
  976.     TypeSymbol *MustFindType(Ast *);
  977.     void ProcessInterface(TypeSymbol *, AstExpression *);
  978.  
  979.     void InitializeVariable(AstFieldDeclaration *, Tuple<VariableSymbol *> &);
  980.     void ProcessInitializer(AstBlock *, AstBlock *, MethodSymbol *, Tuple<VariableSymbol *> &);
  981.     bool NeedsInitializationMethod(AstFieldDeclaration *);
  982.     void ProcessStaticInitializers(AstClassBody *);
  983.     void ProcessBlockInitializers(AstClassBody *);
  984.  
  985.     bool CanWideningPrimitiveConvert(TypeSymbol *, TypeSymbol *);
  986.     bool CanNarrowingPrimitiveConvert(TypeSymbol *, TypeSymbol *);
  987.     bool CanCastConvert(TypeSymbol *, TypeSymbol *, LexStream::TokenIndex);
  988.     bool CanMethodInvocationConvert(TypeSymbol *, TypeSymbol *);
  989.     bool CanAssignmentConvert(TypeSymbol *, AstExpression *);
  990.     bool CanAssignmentConvertReference(TypeSymbol *, TypeSymbol *);
  991.     LiteralValue *CastPrimitiveValue(TypeSymbol *, AstExpression *);
  992.     LiteralValue *CastValue(TypeSymbol *, AstExpression *);
  993.     AstExpression *ConvertToType(AstExpression *, TypeSymbol *);
  994.     AstExpression *PromoteUnaryNumericExpression(AstExpression *);
  995.     void BinaryNumericPromotion(AstAssignmentExpression *);
  996.     void BinaryNumericPromotion(AstBinaryExpression *);
  997.     void BinaryNumericPromotion(AstConditionalExpression *);
  998.  
  999.     void (Semantic::*DefiniteStmt[Ast::_num_kinds])(Ast *);
  1000.     inline void DefiniteStatement(Ast *);
  1001.  
  1002.     void DefiniteLoopBody(AstStatement *);
  1003.  
  1004.     void DefiniteBlock(Ast *);
  1005.     void DefiniteLocalVariableDeclarationStatement(Ast *);
  1006.     void DefiniteExpressionStatement(Ast *);
  1007.     void DefiniteSynchronizedStatement(Ast *);
  1008.     void DefiniteIfStatement(Ast *);
  1009.     void DefiniteWhileStatement(Ast *);
  1010.     void DefiniteForStatement(Ast *);
  1011.     void DefiniteSwitchStatement(Ast *);
  1012.     void DefiniteDoStatement(Ast *);
  1013.     void DefiniteBreakStatement(Ast *);
  1014.     void DefiniteContinueStatement(Ast *);
  1015.     void DefiniteReturnStatement(Ast *);
  1016.     void DefiniteThrowStatement(Ast *);
  1017.     void DefiniteTryStatement(Ast *);
  1018.     void DefiniteEmptyStatement(Ast *);
  1019.     void DefiniteClassDeclaration(Ast *);
  1020.  
  1021.     VariableSymbol *DefiniteFinal(AstFieldAccess *);
  1022.  
  1023.     DefiniteAssignmentSet *(Semantic::*DefiniteExpr[Ast::_num_expression_kinds])(AstExpression *, BitSet &);
  1024.     DefiniteAssignmentSet *DefiniteSimpleName(AstExpression *, BitSet &);
  1025.     DefiniteAssignmentSet *DefiniteArrayAccess(AstExpression *, BitSet &);
  1026.     DefiniteAssignmentSet *DefiniteMethodInvocation(AstExpression *, BitSet &);
  1027.     DefiniteAssignmentSet *DefiniteClassInstanceCreationExpression(AstExpression *, BitSet &);
  1028.     DefiniteAssignmentSet *DefiniteArrayCreationExpression(AstExpression *, BitSet &);
  1029.     DefiniteAssignmentSet *DefinitePreUnaryExpression(AstExpression *, BitSet &);
  1030.     DefiniteAssignmentSet *DefinitePostUnaryExpression(AstExpression *, BitSet &);
  1031.     DefiniteAssignmentSet *DefiniteBinaryExpression(AstExpression *, BitSet &);
  1032.     DefiniteAssignmentSet *DefiniteConditionalExpression(AstExpression *, BitSet &);
  1033.     DefiniteAssignmentSet *DefiniteAssignmentExpression(AstExpression *, BitSet &);
  1034.     DefiniteAssignmentSet *DefiniteDefaultExpression(AstExpression *, BitSet &);
  1035.     DefiniteAssignmentSet *DefiniteFieldAccess(AstExpression *, BitSet &);
  1036.     DefiniteAssignmentSet *DefiniteParenthesizedExpression(AstExpression *, BitSet &);
  1037.     DefiniteAssignmentSet *DefiniteCastExpression(AstExpression *, BitSet &);
  1038.     DefiniteAssignmentSet *DefiniteExpression(AstExpression *, BitSet &);
  1039.  
  1040.     DefiniteAssignmentSet *(Semantic::*DefinitePreUnaryExpr[AstPreUnaryExpression::_num_kinds])(AstExpression *, BitSet &);
  1041.     DefiniteAssignmentSet *DefiniteDefaultPreUnaryExpression(AstExpression *, BitSet &);
  1042.     DefiniteAssignmentSet *DefiniteNOT(AstExpression *, BitSet &);
  1043.     DefiniteAssignmentSet *DefinitePLUSPLUSOrMINUSMINUS(AstExpression *, BitSet &);
  1044.  
  1045.     DefiniteAssignmentSet *(Semantic::*DefiniteBinaryExpr[AstBinaryExpression::_num_kinds])(AstBinaryExpression *, BitSet &);
  1046.     DefiniteAssignmentSet *DefiniteDefaultBinaryExpression(AstBinaryExpression *, BitSet &);
  1047.     DefiniteAssignmentSet *DefiniteAND(AstBinaryExpression *, BitSet &);
  1048.     DefiniteAssignmentSet *DefiniteIOR(AstBinaryExpression *, BitSet &);
  1049.     DefiniteAssignmentSet *DefiniteXOR(AstBinaryExpression *, BitSet &);
  1050.     DefiniteAssignmentSet *DefiniteAND_AND(AstBinaryExpression *, BitSet &);
  1051.     DefiniteAssignmentSet *DefiniteOR_OR(AstBinaryExpression *, BitSet &);
  1052.     DefiniteAssignmentSet *DefiniteEQUAL_EQUAL(AstBinaryExpression *, BitSet &);
  1053.     DefiniteAssignmentSet *DefiniteNOT_EQUAL(AstBinaryExpression *, BitSet &);
  1054.  
  1055.     DefiniteAssignmentSet *DefiniteAssignmentAND(TypeSymbol *, BitSet *, BitSet &, DefiniteAssignmentSet *, DefiniteAssignmentSet *);
  1056.     DefiniteAssignmentSet *DefiniteAssignmentIOR(TypeSymbol *, BitSet *, BitSet &, DefiniteAssignmentSet *, DefiniteAssignmentSet *);
  1057.     DefiniteAssignmentSet *DefiniteAssignmentXOR(TypeSymbol *, BitSet *, BitSet &, DefiniteAssignmentSet *, DefiniteAssignmentSet *);
  1058.  
  1059.     void DefiniteArrayInitializer(AstArrayInitializer *);
  1060.     void DefiniteVariableInitializer(AstVariableDeclarator *);
  1061.     void DefiniteBlockStatements(AstBlock *);
  1062.     void DefiniteMethodBody(AstMethodDeclaration *, Tuple<VariableSymbol *> &);
  1063.     void DefiniteConstructorBody(AstConstructorDeclaration *, Tuple<VariableSymbol *> &);
  1064.     void DefiniteBlockInitializer(AstBlock *, int, Tuple<VariableSymbol *> &);
  1065.     void DefiniteVariableInitializer(AstVariableDeclarator *, Tuple<VariableSymbol *> &);
  1066.  
  1067.     void ProcessBlockStatements(AstBlock *);
  1068.     void ProcessThisCall(AstThisCall *);
  1069.     void ProcessSuperCall(AstSuperCall *);
  1070.     void CheckThrow(AstExpression *);
  1071.     void ProcessMethodBody(AstMethodDeclaration *);
  1072.     void ProcessConstructorBody(AstConstructorDeclaration *, bool);
  1073.     bool CatchableException(TypeSymbol *);
  1074.     void ReportMethodNotFound(Ast *ast, wchar_t *);
  1075.     MethodSymbol *FindConstructor(TypeSymbol *, Ast *, LexStream::TokenIndex, LexStream::TokenIndex);
  1076.     bool MoreSpecific(MethodSymbol *, MethodSymbol *);
  1077.     bool MoreSpecific(MethodSymbol *, Tuple<MethodSymbol *> &);
  1078.     bool NoMethodMoreSpecific(Tuple<MethodSymbol *> &, MethodSymbol *);
  1079.     bool IsMethodAccessible(AstFieldAccess *, TypeSymbol *, MethodSymbol *);
  1080.     void SearchForMethodInEnvironment(Tuple<MethodSymbol *> &, SemanticEnvironment *&, SemanticEnvironment *, AstMethodInvocation *);
  1081.     MethodSymbol *FindMisspelledMethodName(TypeSymbol *, AstMethodInvocation *, NameSymbol *);
  1082.     MethodSymbol *FindMethodInEnvironment(SemanticEnvironment *&, SemanticEnvironment *, AstMethodInvocation *);
  1083.     MethodSymbol *FindMethodInType(TypeSymbol *, AstMethodInvocation *, NameSymbol * = NULL);
  1084.  
  1085.     void ReportAccessedFieldNotFound(AstFieldAccess *, TypeSymbol *);
  1086.     void SearchForVariableInEnvironment(Tuple<VariableSymbol *> &, SemanticEnvironment *&,
  1087.                                         SemanticEnvironment *, NameSymbol *, LexStream::TokenIndex);
  1088.     VariableSymbol *FindMisspelledVariableName(TypeSymbol *, LexStream::TokenIndex);
  1089.     VariableSymbol *FindVariableInEnvironment(SemanticEnvironment *&, SemanticEnvironment *, LexStream::TokenIndex);
  1090.     VariableSymbol *FindVariableInType(TypeSymbol *, AstFieldAccess *, NameSymbol * = NULL);
  1091.     VariableSymbol *FindInstance(TypeSymbol *, TypeSymbol *);
  1092.     AstExpression *CreateAccessToType(Ast *, TypeSymbol *);
  1093.     void CreateAccessToScopedVariable(AstSimpleName *, TypeSymbol *);
  1094.     void CreateAccessToScopedMethod(AstMethodInvocation *, TypeSymbol *);
  1095.  
  1096.     void TypeAccessCheck(Ast *, TypeSymbol *);
  1097.     void TypeNestAccessCheck(AstExpression *);
  1098.     void ConstructorAccessCheck(AstClassInstanceCreationExpression *, MethodSymbol *);
  1099.     void MemberAccessCheck(AstFieldAccess *, TypeSymbol *, Symbol *);
  1100.     void SimpleNameAccessCheck(AstSimpleName *, TypeSymbol *, Symbol *);
  1101.  
  1102.     void (Semantic::*ProcessPreUnaryExpr[AstPreUnaryExpression::_num_kinds])(AstPreUnaryExpression *);
  1103.     void ProcessPLUS(AstPreUnaryExpression *);
  1104.     void ProcessMINUS(AstPreUnaryExpression *);
  1105.     void ProcessTWIDDLE(AstPreUnaryExpression *);
  1106.     void ProcessNOT(AstPreUnaryExpression *);
  1107.     void ProcessPLUSPLUSOrMINUSMINUS(AstPreUnaryExpression *);
  1108.  
  1109.     void (Semantic::*ProcessBinaryExpr[AstBinaryExpression::_num_kinds])(AstBinaryExpression *);
  1110.     void ProcessPLUS(AstBinaryExpression *);
  1111.     void ProcessLEFT_SHIFT(AstBinaryExpression *);
  1112.     void ProcessRIGHT_SHIFT(AstBinaryExpression *);
  1113.     void ProcessUNSIGNED_RIGHT_SHIFT(AstBinaryExpression *);
  1114.     void ProcessLESS(AstBinaryExpression *);
  1115.     void ProcessGREATER(AstBinaryExpression *);
  1116.     void ProcessLESS_EQUAL(AstBinaryExpression *);
  1117.     void ProcessGREATER_EQUAL(AstBinaryExpression *);
  1118.     void ProcessAND(AstBinaryExpression *);
  1119.     void ProcessXOR(AstBinaryExpression *);
  1120.     void ProcessIOR(AstBinaryExpression *);
  1121.     void ProcessAND_AND(AstBinaryExpression *);
  1122.     void ProcessOR_OR(AstBinaryExpression *);
  1123.     void ProcessEQUAL_EQUAL(AstBinaryExpression *);
  1124.     void ProcessNOT_EQUAL(AstBinaryExpression *);
  1125.     void ProcessSTAR(AstBinaryExpression *);
  1126.     void ProcessMINUS(AstBinaryExpression *);
  1127.     void ProcessSLASH(AstBinaryExpression *);
  1128.     void ProcessMOD(AstBinaryExpression *);
  1129.     void ProcessINSTANCEOF(AstBinaryExpression *);
  1130.  
  1131.     MethodSymbol *FindMethodMember(TypeSymbol *, TypeSymbol *, AstMethodInvocation *);
  1132.     void ProcessMethodName(AstMethodInvocation *);
  1133.     void (Semantic::*ProcessExprOrStmt[Ast::_num_kinds])(Ast *);
  1134.     inline void ProcessStatement(AstStatement *stmt)
  1135.     {
  1136.         (this ->* ProcessExprOrStmt[stmt -> kind])(stmt);
  1137.     }
  1138.  
  1139.     inline void ProcessExpression(AstExpression *expr)
  1140.     {
  1141.         (this ->* ProcessExprOrStmt[expr -> kind])(expr);
  1142.     }
  1143.  
  1144.     inline void ProcessExpressionOrStringConstant(AstExpression *expr)
  1145.     {
  1146.         (this ->* ProcessExprOrStmt[expr -> kind])(expr);
  1147.         //
  1148.         // If the expression is of type String, check whether or not it is
  1149.         // constant, and if so, compute the result.
  1150.         //
  1151.         if (expr -> symbol == control.String() && (! expr -> IsConstant()))
  1152.             control.Utf8_pool.CheckStringConstant(expr);
  1153.  
  1154.         return;
  1155.     }
  1156.  
  1157.     void ProcessLocalVariableDeclarationStatement(Ast *);
  1158.     void ProcessBlock(Ast *);
  1159.     void ProcessForStatement(Ast *);
  1160.     void ProcessSwitchStatement(Ast *);
  1161.     void ProcessThrowStatement(Ast *);
  1162.     void ProcessTryStatement(Ast *);
  1163.     void ProcessExpressionStatement(Ast *);
  1164.     void ProcessSynchronizedStatement(Ast *);
  1165.     void ProcessIfStatement(Ast *);
  1166.     void ProcessWhileStatement(Ast *);
  1167.     void ProcessDoStatement(Ast *);
  1168.     void ProcessBreakStatement(Ast *);
  1169.     void ProcessContinueStatement(Ast *);
  1170.     void ProcessReturnStatement(Ast *);
  1171.     void ProcessEmptyStatement(Ast *);
  1172.     TypeSymbol *GetLocalType(AstClassDeclaration *);
  1173.     void ProcessClassDeclaration(Ast *);
  1174.     void GenerateLocalConstructor(MethodSymbol *);
  1175.  
  1176.     void CheckSimpleName(AstSimpleName *, SemanticEnvironment *where_found);
  1177.     void ProcessSimpleName(Ast *);
  1178.     void FindVariableMember(TypeSymbol *, TypeSymbol *, AstFieldAccess *);
  1179.     void ProcessAmbiguousName(Ast *);
  1180.     void ProcessFieldAccess(Ast *);
  1181.     void ProcessIntegerLiteral(Ast *);
  1182.     void ProcessLongLiteral(Ast *);
  1183.     void ProcessFloatingPointLiteral(Ast *);
  1184.     void ProcessDoubleLiteral(Ast *);
  1185.     void ProcessTrueLiteral(Ast *);
  1186.     void ProcessFalseLiteral(Ast *);
  1187.     void ProcessStringLiteral(Ast *);
  1188.     void ProcessCharacterLiteral(Ast *);
  1189.     void ProcessArrayAccess(Ast *);
  1190.     void ProcessMethodInvocation(Ast *);
  1191.     void ProcessNullLiteral(Ast *);
  1192.     void ProcessThisExpression(Ast *);
  1193.     void ProcessSuperExpression(Ast *);
  1194.     void ProcessParenthesizedExpression(Ast *);
  1195.     void UpdateGeneratedLocalConstructor(MethodSymbol *);
  1196.     void UpdateLocalConstructors(TypeSymbol *);
  1197.     void GetAnonymousConstructor(AstClassInstanceCreationExpression *, TypeSymbol *);
  1198.     TypeSymbol *GetAnonymousType(AstClassInstanceCreationExpression *, TypeSymbol *);
  1199.     void ProcessClassInstanceCreationExpression(Ast *);
  1200.     void ProcessArrayCreationExpression(Ast *);
  1201.     void ProcessPostUnaryExpression(Ast *);
  1202.     void ProcessPreUnaryExpression(Ast *);
  1203.     void ProcessCastExpression(Ast *);
  1204.     void ProcessBinaryExpression(Ast *);
  1205.     void ProcessTypeExpression(Ast *);
  1206.     void ProcessConditionalExpression(Ast *);
  1207.     void ProcessAssignmentExpression(Ast *);
  1208.  
  1209.     void ProcessVariableInitializer(AstVariableDeclarator *);
  1210.     void ProcessArrayInitializer(AstArrayInitializer *, TypeSymbol *);
  1211.  
  1212.     void CheckInheritedMethodThrows(AstMethodDeclaration *, MethodSymbol *);
  1213.     void CheckMethodOverride(AstMethodDeclaration *, MethodSymbol *);
  1214.     void CheckInheritedMethodThrows(AstClassDeclaration *, MethodSymbol *, MethodSymbol *);
  1215.     void CheckMethodOverride(AstClassDeclaration *, MethodSymbol *, MethodSymbol *);
  1216.     void AddInheritedTypes(TypeSymbol *, TypeSymbol *);
  1217.     void AddInheritedFields(TypeSymbol *, TypeSymbol *);
  1218.     void AddInheritedMethods(TypeSymbol *, TypeSymbol *, LexStream::TokenIndex);
  1219.     void ComputeTypesClosure(TypeSymbol *, LexStream::TokenIndex);
  1220.     void ComputeFieldsClosure(TypeSymbol *, LexStream::TokenIndex);
  1221.     void ComputeMethodsClosure(TypeSymbol *, LexStream::TokenIndex);
  1222.  
  1223.     inline bool InRange(char *buffer_ptr, char *buffer_tail, int size) { return ((buffer_ptr + size) <= buffer_tail); }
  1224.     TypeSymbol *RetrieveNestedTypes(TypeSymbol *, wchar_t *, LexStream::TokenIndex);
  1225.     TypeSymbol *GetClassPool(TypeSymbol *, TypeSymbol **, char **, int, LexStream::TokenIndex);
  1226.     void ProcessBadClass(TypeSymbol *, LexStream::TokenIndex);
  1227.     bool ProcessClassFile(TypeSymbol *, char *, int, LexStream::TokenIndex);
  1228.     void ReadClassFile(TypeSymbol *, LexStream::TokenIndex);
  1229.  
  1230.     //
  1231.     // Any exception that is neither RuntimeException or one of its subclasses nor
  1232.     // Error or one of its subclasses is a checked exception.
  1233.     //
  1234.     inline bool CheckedException(TypeSymbol *exception)
  1235.     {
  1236.         return (! (exception -> IsSubclass(control.RuntimeException()) || exception -> IsSubclass(control.Error())));
  1237.     }
  1238.  
  1239. public:
  1240.  
  1241.     static inline u1 GetU1(char *);
  1242.     static inline u2 GetU2(char *);
  1243.     static inline u4 GetU4(char *);
  1244.  
  1245.     static inline u1 GetAndSkipU1(char *&);
  1246.     static inline u2 GetAndSkipU2(char *&);
  1247.     static inline u4 GetAndSkipU4(char *&);
  1248.     static inline void Skip(char *&, int);
  1249.  
  1250.     inline void AddDependence(TypeSymbol *, TypeSymbol *, LexStream::TokenIndex, bool = false);
  1251.     inline void SetObjectSuperType(TypeSymbol *, LexStream::TokenIndex);
  1252.     inline void AddStringConversionDependence(TypeSymbol *, LexStream::TokenIndex);
  1253. };
  1254.  
  1255.  
  1256. inline void Semantic::AddDependence(TypeSymbol *base_type_, TypeSymbol *parent_type_, LexStream::TokenIndex tok, bool static_access)
  1257. {
  1258.     if (base_type_ != control.no_type)
  1259.     {
  1260.         TypeSymbol *base_type = base_type_ -> outermost_type,
  1261.                    *parent_type = parent_type_ -> outermost_type;
  1262.  
  1263.         parent_type -> dependents -> AddElement(base_type);
  1264.         if (static_access)
  1265.              base_type -> static_parents -> AddElement(parent_type);
  1266.         else base_type -> parents -> AddElement(parent_type);
  1267.  
  1268.         if (control.option.pedantic)
  1269.         {
  1270.             if (parent_type -> ContainingPackage() == control.unnamed_package &&
  1271.                 base_type -> ContainingPackage() != control.unnamed_package)
  1272.             {
  1273.                 error -> Report(SemanticError::PARENT_TYPE_IN_UNNAMED_PACKAGE,
  1274.                                 tok,
  1275.                                 tok,
  1276.                                 parent_type_ -> ContainingPackage() -> PackageName(),
  1277.                                 parent_type_ -> ExternalName());
  1278.             }
  1279.         }
  1280.     }
  1281.  
  1282.     return;
  1283. }
  1284.  
  1285. inline void Semantic::SetObjectSuperType(TypeSymbol *type, LexStream::TokenIndex tok)
  1286. {
  1287.     type -> super = control.Object();
  1288.     AddDependence(type, type -> super, tok);
  1289. }
  1290.  
  1291. inline void Semantic::AddStringConversionDependence(TypeSymbol *type, LexStream::TokenIndex tok)
  1292. {
  1293.     if (type == control.null_type)
  1294.          ;
  1295.     else if (type == control.boolean_type)
  1296.          AddDependence(ThisType(), control.Boolean(), tok);
  1297.     else if (type == control.char_type)
  1298.          AddDependence(ThisType(), control.Character(), tok);
  1299.     else if (type == control.int_type)
  1300.          AddDependence(ThisType(), control.Integer(), tok);
  1301.     else if (type == control.long_type)
  1302.          AddDependence(ThisType(), control.Long(), tok);
  1303.     else if (type == control.float_type)
  1304.          AddDependence(ThisType(), control.Float(), tok);
  1305.     else // (type == control.double_type)
  1306.          AddDependence(ThisType(), control.Double(), tok);
  1307. }
  1308. #endif
  1309.